home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2417 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Hungarian notation
  5. Date: Wed, 17 Jan 96 15:01:10 GMT
  6. Organization: none
  7. Message-ID: <821890870snz@genesis.demon.co.uk>
  8. References: <4dhkae$an9@blackice.winternet.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4dhkae$an9@blackice.winternet.com>
  15.            jdege@winternet.com "Jeff Dege" writes:
  16.  
  17. >    Generally speaking, when I use printf(), et al., with integer types
  18. >of uncertain or unknown size, I explicitly cast.  i.e.:
  19. >
  20. >printf("The current epoch is %ld\n", (long) time(NULL));
  21. >
  22. >    This is, as far as I know, the only safe way to printf() a time_t, 
  23. >size_t, etc.
  24.  
  25. There is no guarantee that time_t is an integer. To print it safely you
  26. should cast it to long double. size_t is guaranteed to be an unsigned
  27. integer so it should be cast to unsigned long for printing.
  28.  
  29. -- 
  30. -----------------------------------------
  31. Lawrence Kirby | fred@genesis.demon.co.uk
  32. Wilts, England | 70734.126@compuserve.com
  33. -----------------------------------------
  34.